Skip to content

Feature/async - v2.0 release candidate - #75

Closed
MarTrepodi wants to merge 20 commits into
mainfrom
feature/async
Closed

Feature/async - v2.0 release candidate#75
MarTrepodi wants to merge 20 commits into
mainfrom
feature/async

Conversation

@MarTrepodi

Copy link
Copy Markdown
Collaborator

Description

This PR represents the final collection of updates needed to address all outstanding issues related to the stated updates for the v2.0.0 major update.

Related Issues

Closes #51, #72, #63, #62, #61, #60

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Documentation
  • Tests

Checklist

  • My commits follow the Angular commit convention (feat:, fix:, refactor:, etc.)
  • I have added/updated docstrings with type hints for any new or changed public methods
  • I have added unit tests that cover my changes (mocked, not requiring a live comlink service)
  • All existing tests still pass (python -m pytest tests/ -v)
  • Ruff linter passes (ruff check src/ tests/)

Testing

Full current suite of pytests and manual spot validation using samples from the examples folder

MarTrepodi and others added 19 commits March 3, 2026 09:21
….18.0rc1

Add the StatCalc local stat/GP calculator, fix multiple bugs in
calculator.py (duplicate _rename_stats call, calc_player_stats type
errors, print statements), update all documentation to reflect the
StatCalc feature, and remove unused verify-upstream.sh script.
Version set to 1.18.0rc1 for release candidate publication alongside
the stable PyPI release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace `requests` with `httpx` for sync/async HTTP support
- Extract shared logic into `SwgohComlinkBase` abstract base class
- Add `SwgohComlinkAsync` with identical API using async/await
- Refactor logging to follow Python library best practices (NullHandler only)
- Mask `secret_key` and `access_key` in `__repr__` and debug logging
- Add `_SENSITIVE_KEYS` frozenset and `_mask()` helper for consistent masking
- Sanitize kwargs in `func_debug_logger` to prevent credential leakage
- Add type annotations to Google-style docstrings for mkdocstrings
- Add mkdocs build step to CI workflow with `--strict` mode
- Add `SwgohComlinkAsync` API reference page to docs
- Update README with dedicated Async and StatCalc sections
- Rewrite `docs/logging.md` for NullHandler approach
- Add 110 unit tests (100% coverage on core modules)
- Introduce `docs/migration.md` covering dependency updates, exception handling, logging changes, and client lifecycle.
- Add migration summary to the README with key actions and a link to the full guide.
- Update `mkdocs.yml` to include the migration guide in the navigation.
…ncio-based scripts

- Removed the outdated `threaded_player_fetch.py` script.
- Added multiple new examples utilizing `SwgohComlinkAsync`, including:
  - `async/concurrent_requests.py`
  - `async/streaming_guild_roster.py`
  - `async/get_guild_leaderboard.py` and more for async capabilities.
- Updated `examples/README.md` with descriptions and directory structure for better organization between `Sync` and `Async` examples.
…oading

- Added `GameDataBuilder` and `GameDataBuilderAsync` modules to support dynamic game data generation from a running Comlink service instead of relying on static files.
- Enhanced README, API docs, and examples to demonstrate the use of `GameDataBuilder`.
- Updated examples for both sync and async workflows to showcase dynamic and static approaches to stat calculation.
- Updated `CHANGELOG.md` and bumped `StatCalc` functionality for this addition.
Refactor 1,970-line helpers.py into a focused helpers/ subpackage with
12 domain-specific modules. Consolidate 4 duplicate copies of stat data
into a single canonical source in _stat_data.py, eliminating ~800 lines
of redundancy including the 489-line inline STATS_NAME_MAP in
StatCalc/calculator.py. All existing import paths preserved via
backward-compatible re-export shim.

Add swgoh-migrate CLI tool (python -m swgoh_comlink.migrate) for
scanning user codebases to identify deprecated imports, API changes,
and migration steps needed when upgrading from v1.x.

Rewrite legacy test_get_enums and test_get_unit_stats from
requests/mock.patch to pytest-httpx, fixing 5 test failures.
…ulation

- Added logic to calculate and aggregate dismantle materials across multiple datacrons.
- Updated return type from `list` to `dict` for clearer representation of totals.
- Enhanced docstrings with detailed descriptions and type hints.
…t entries

- Grouped stat data imports in `helpers/__init__.py` for better organization and consistency.
- Removed unnecessary blank lines in `test_get_enums.py` and `test_parity.py`.
- Fixed minor import reordering in `_guild.py` for clarity.
- Corrected type hint formatting in `StatCalcAsync.create` method definition.
…nce CI

- Added fixtures in `conftest.py` for shared HMAC/Async test setup.
- Introduced new integration tests for HMAC and async clients, covering both valid and invalid key scenarios.
- Enhanced CI pipeline to include Python 3.14 and integration tests using separate workflows.
- Added integration tests for `SwgohComlink` and `SwgohComlinkAsync` clients, validating enums, metadata, events, and player-related operations.
…ight sentinel class

- Implemented custom `Sentinel` class to remove dependency on the external `sentinels` package.
- Updated `_sentinels.py` with the new implementation and revised sentinel definitions.
- Removed `sentinels` from `pyproject.toml` and lockfiles.
- Refactored `__all__` exports and updated imports to reflect the changes.
- Introduced comprehensive `Helpers` and `Exceptions` API reference documentation.
- Enriched `docs/index.md` with links to the new `Helpers` and `Exceptions` docs.
- Updated `mkdocs.yml` to include the new files in the navigation structure.
- Expanded helper module with new async methods for GAC and guild operations.
…GAC bracket handling

- Deleted `OPTIONAL` and `NotSet` sentinels from `helpers` and replaced their usage with type-based defaults (e.g., `None`, `int`).
- Updated `get_gac_brackets()` and `async_get_gac_brackets()` to use int-based `limit` parameter with a default value of `0` (no limit).
- Introduced exponential probing with binary search for GAC bracket boundary detection, optimizing performance from O(n) to O(log n).
- Added parallel batch fetching to `async_get_gac_brackets()` for faster operations via `asyncio.gather`.
- Adjusted docs, migration guide, and tests to align with these updates.
…patibility

- Updated payload serialization to use an empty string (`""`) instead of an empty object (`{}`) when no payload is provided, ensuring compatibility with comlink v4 (#51).
- Added unit test to verify updated behavior and prevent regressions.
- Added explicit checks and error handling for Comlink and HMAC readiness.
- Introduced environment variables for better service identification.
- Enhanced error reporting on service startup failures.
…diness checks

- Expanded commit message scopes in `commitlint` to include additional categories (`version`,
`hmac`, `async`, etc.).
- Dropped Python 3.14 from CI matrix in `ci.yml`.
- Enhanced integration workflow:
  - Changed branch filters to reflect new maintenance structure.
  - Added health checks for services with improved startup readiness validation.
  - Updated `/metadata` endpoint to `/readyz` for readiness checks.
- Adjusted branch filters in `commitlint.yml` and `ci.yml` to include `1.0-maintenance`.
- Removed `--strict` flag from the documentation build step in `test.yml`.
- Replaced generic types with more precise annotations (e.g., `dict` → `dict[str, Any]`).
- Added `cast` and `assert` statements for stricter runtime type validation.
- Improved validation for player allycodes and guild IDs with custom exceptions.
- Updated decorators to include detailed type hints for improved clarity.
@github-actions github-actions Bot added documentation Improvements or additions to documentation ci Changes related to continuous integration processes dependencies Updates to package dependency libraries code testing labels Mar 7, 2026
…mports

- Combined nested `with` statements in HMAC tests for cleaner exception handling.
- Removed unused `pytest` import from `test_gac_helpers.py`.
@MarTrepodi MarTrepodi closed this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Changes related to continuous integration processes code dependencies Updates to package dependency libraries documentation Improvements or additions to documentation testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update HMAC signing default empty object for comlink v4

1 participant